Glulx Text Effects (for Glulx only) by Emily Short begins here.

"Glulx Text Effects provides an easy way to set up special text effects for Glulx."

text-justification is a kind of value. The text-justifications are left-justified, left-right-justified, center-justified, and right-justified. 

special-style is a kind of value. The special-styles are special-style-1 and special-style-2. 

boldness is a kind of value. The boldnesses are light-weight, regular-weight, and bold-weight.

obliquity is a kind of value.  The obliquities are no-obliquity and italic-obliquity.

fixity is a kind of value. The fixities are fixed-width-font and proportional-font.

Before starting the virtual machine:
	initialize user styles.
	
Table of User Styles
style name	justification	obliquity	indentation	first-line indentation	boldness	fixed width	relative size
a special-style		a text-justification	an obliquity	a number	a number	a boldness	a fixity	a number


To initialize user styles:
	repeat through the Table of User Styles
	begin; 
		apply justification of (justification entry) to (style name entry);
		apply obliquity (obliquity entry) to (style name entry);
		apply (indentation entry) indentation to (style name entry);
		apply (first-line indentation entry) first-line indentation to (style name entry);
		apply (boldness entry) boldness to (style name entry);
		apply fixed-width-ness (fixed width entry) to (style name entry);
		apply (relative size entry) size-change to (style name entry);
	end repeat.
	
To apply (relative size change - a number) size-change to (chosen style - a special-style):
	(- SetSize({chosen style}, {relative size change}); -)
	
To apply (chosen boldness - a boldness) boldness to (chosen style - a special-style):
	(- BoldnessSet({chosen style}, {chosen boldness}); -)
	
To apply (indentation amount - a number) indentation to (chosen style - a special-style):
	(- Indent({chosen style}, {indentation amount}); -)
	
To apply (indentation amount - a number) first-line indentation to (chosen style - a special-style):
	(- ParaIndent({chosen style}, {indentation amount}); -)

To apply justification of (justify - a text-justification) to (chosen style - a special-style):
	(- Justification({justify}, {chosen style}); -)
	
To apply fixed-width-ness (chosen fixity - a fixity) to (chosen style - a special-style):
	(- FixitySet({chosen style}, {chosen fixity}); -)
	
To apply obliquity (chosen obliquity - an obliquity) to (chosen style - a special-style):
	(- Obliquify({chosen style}, {chosen obliquity}); -)
	
Include (-

[ FixitySet S N;
	S=S+8; 
	N--;
	glk_stylehint_set(wintype_TextBuffer, S, stylehint_Proportional, N); 
];

[ SetSize S N;
	S=S+8;  
	glk_stylehint_set(wintype_TextBuffer, S, stylehint_Size, N); 
];

[ BoldnessSet S N;
	S=S+8; 
	N = N-2;
	glk_stylehint_set(wintype_TextBuffer, S, stylehint_Weight, N); 
];

[ ParaIndent S N;
	S=S+8; 
	glk_stylehint_set(wintype_TextBuffer, S, stylehint_ParaIndentation, N); 
];

[ Indent S N;
	S=S+8; 
	glk_stylehint_set(wintype_TextBuffer, S, stylehint_Indentation, N); 
];

[ Justification N S;
	N--; S=S+8; 
	glk_stylehint_set(wintype_TextBuffer, S, stylehint_Justification, N); 
];

[ Obliquify S N;
	S=S+8;
	N--;
	glk_stylehint_set(wintype_TextBuffer, S, stylehint_Oblique, N); 
];

-)
	

To say first custom style:
	(- glk_set_style(style_User1); -)

To say second custom style:
	(- glk_set_style(style_User2); -)
 

Glulx Text Effects ends here.

---- Documentation ----

Glulx Text Effects provides an easy way to set up special text effects for Glulx. 

Unlike the z-machine, which allows arbitrary combinations of features (such as color and boldness) to be applied to text, Glulx requires the author to define and then use text styles.

A text style in Glulx can have the following features:

	indentation: the number of units of indentation for the whole block of text, where units are defined by interpreter, but are often equivalent to spaces
	first-line indentation: relative indentation of the first line of the text block
	justification: can be left-justified, right-justified, justified on both the left and the right, or centered
	obliqueness: whether the font is italic or not
	weight: may be light, regular, or bold
	relative size: increase (or decrease) from the regular font size being used

It is also possible to set font color, but this is more complicated than in the z-machine and is not handled by Glulx Text Effects.

A number of styles are predefined by Glulx. The author is also allowed to define two text styles of his own, which we will call special-style-1 and special-style-2. 

To set up style instructions with Glulx Text Effects, we create a table, like this:

	Table of User Styles (continued)
	style name	justification	obliquity	indentation	first-line indentation	boldness	fixed width	relative size
	special-style-1	center-justified	no-obliquity	0	0	regular-weight	proportional-font	0
	special-style-2	right-justified	italic-obliquity	0	4	regular-weight	proportional-font	0
	
Note that we *may* have multiple lines in this table referring to the same style. In that case, the last such line is the one that will take effect. This means that if the author is using an extension that includes a table of user styles, he may further continue the table in order to edit the styles defined by that extension.

The names of the style names (special-style-1 and special-style-2) may not be changed. However, we may set the justification to any of these:

	left-justified
	right-justified
	left-right-justified	
	center-justified

We may set the obliquity to 

	no-obliquity
	italic-obliquity

We may set the indentation and first-line indentation to numbers.

We may set the boldness to 

	light-weight
	regular-weight
	bold-weight

We may set fixed width to	
	
	proportional-font
	fixed-width-font

Finally, we set relative size to a number. This indicates by how many points the font size should be changed from the baseline size: a positive number if this text style should be larger than normal, a negative one if smaller. 

Once we have defined custom text styles, we may invoke them ourselves with

	say first custom style
	say second custom style 

Example: * The Gallic War - An excuse to print a large, fancily-formatted bit of text

	"The Gallic War" by Julius Caesar.

	The story headline is "An interactive campaign".

	Include Glulx Text Effects by Emily Short. Include Basic Screen Effects by Emily Short.

	Table of User Styles (continued)
	style name	justification	obliquity	indentation	first-line indentation	boldness	fixed width	relative size
	special-style-2	left-right-justified	italic-obliquity	15	-4	light-weight	proportional-font	0  

	When play begins:
		change left hand status line to ""; change right hand status line to "";
		say "[second custom style]Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit. 

Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt. Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.";
		pause the game;
		say roman type;
		change left hand status line to "[location]"; change right hand status line to "[turn count]".

	Bank of the Garumna is a room.
